package com.example.zhujiemian.txlb;


import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;


import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.zhujiemian.GerenxinxiActivity;
import com.example.zhujiemian.R;
import com.example.zhujiemian.TwoActivity;
import com.example.zhujiemian.kecheng;

import java.util.ArrayList;
        import java.util.List;

public class FlowerAdapterActivity extends AppCompatActivity implements FlowerAdapter.OnFlowerEditListener {

    private RecyclerView recyclerView;
    private FlowerAdapter adapter;
    private RecyclerView.LayoutManager layoutManager;
    private List<Flower> flowers;

    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_txlb);


        recyclerView = findViewById(R.id.recycler_view);
        layoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(layoutManager);

        flowers = new ArrayList<>();
        // 添加同学的数据到列表
        flowers.add(new Flower("一一", 15, "f606"));
        flowers.add(new Flower("二二", 13, "f607"));
        flowers.add(new Flower("三三", 17, "f606"));
        flowers.add(new Flower("四四", 15, "f606"));
        flowers.add(new Flower("五五", 13, "f607"));
        flowers.add(new Flower("六六", 17, "f606"));
        flowers.add(new Flower("七七", 15, "f606"));
        flowers.add(new Flower("八八", 13, "f607"));
        flowers.add(new Flower("九九", 17, "f606"));
        // ... 添加更多同学的数据

        adapter = new FlowerAdapter(this, flowers, this);
        recyclerView.setAdapter(adapter);


    }

    @Override
    public void onFlowerEdited(int position, Flower newFlower) {
        // 更新数据并通知适配器数据已改变
        flowers.set(position, newFlower);
        adapter.notifyItemChanged(position);
    }

    @Override
    public void onFlowerDeleted(int position) {
        // 同学已被适配器删除，这里不需要再做操作
    }

}